import request from '@/utils/request'

// 创建投票规则
export function createInfo(data) {
  return request({
    url: '/vote/info/create',
    method: 'post',
    data: data
  })
}

// 更新投票规则
export function updateInfo(data) {
  return request({
    url: '/vote/info/update',
    method: 'put',
    data: data
  })
}

// 发布投票规则
export function pushVote(data) {
  return request({
    url: '/vote/info/pushVote',
    method: 'put',
    data: data
  })
}

// 删除投票规则
export function deleteInfo(id) {
  return request({
    url: '/vote/info/delete?id=' + id,
    method: 'delete'
  })
}

// 获得投票规则
export function getInfo(id) {
  return request({
    url: '/vote/info/get?id=' + id,
    method: 'get'
  })
}

// 获得最近的投票规则
export function getCurrVote(id) {
  return request({
    url: '/vote/info/getCurrVote',
    method: 'get'
  })
}

// 获得投票规则分页
export function getInfoPage(query) {
  return request({
    url: '/vote/info/page',
    method: 'get',
    params: query
  })
}


// 获得投票名称
export function getVoteName(query) {
  return request({
    url: '/vote/info/list-name',
    method: 'get',
    params: query
  })
}

// 获得投票名称
export function getByUser(query) {
  return request({
    url: '/vote/info/list-by-user',
    method: 'get',
    params: query
  })
}

// 导出投票规则 Excel
export function exportInfoExcel(query) {
  return request({
    url: '/vote/info/export-excel',
    method: 'get',
    params: query,
    responseType: 'blob'
  })
}
export function getQrCode(data){
  return request({
    url: '/vote/info/getQrCode',
    method: 'post',
    data: data,
  })
}

export function copyVote(data){
  return request({
    url: '/vote/info/copyVote',
    method: 'post',
    params: data,
  })
}